home *** CD-ROM | disk | FTP | other *** search
- Path: info.spt.net.cn!usenet
- From: txwang@public.sta.net.cn (Wang TianXing)
- Newsgroups: comp.lang.c++
- Subject: Re: copy ctor and derived classes
- Date: Wed, 17 Jan 1996 13:25:22 GMT
- Organization: Shanghai Post & Telecommunication
- Distribution: world
- Message-ID: <4dit1h$37h@info.sta.net.cn>
- References: <DL38zz.50K@Virginia.EDU>
- NNTP-Posting-Host: ts2-8.sta.net.cn
- X-Newsreader: Forte Free Agent 1.0.82
-
- gcl8a@Virginia.EDU (Gregory Carl Lewin) wrote:
-
- | class Base{
- | int i;
- | public:
- | Base(const Base& b) : i(b.i) {}
- | }
-
- | class Derived : public Base{
- | int j;
- | public:
- | Derived(const Derived& d) : /*tedious i(d.i) */
- | j(d.j) {}
- | };
-
- try this:
-
- class Derived : public Base {
- int j;
- public:
- Derived(const Derived& d) : Base(d), j(d.j) {}
- };
-
- ---
- Wang TianXing
- txwang@public.sta.net.cn
-
-
-